/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.service.impl;

import com.click.app.dao.CategoryDao;
import com.click.app.model.Category;
import com.click.app.model.ProductType;
import com.click.app.service.CategoryManager;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author arnold
 */
public class CategoryManagerImpl extends GenericManagerImpl<Category, Long> implements CategoryManager {

    CategoryDao categoryDao;

    public CategoryManagerImpl(CategoryDao categoryDao) {
        super(categoryDao);
        this.categoryDao = categoryDao;
    }
    public List<Category> findById(Long id) {
        return categoryDao.findById(id);
    }

    public CategoryDao getCategoryDao() {
        return categoryDao;
    }

    public void setCategoryDao(CategoryDao categoryDao) {
        this.categoryDao = categoryDao;
    }
    public List<Category> findCategoryByProductType(ProductType productType){
        return categoryDao.findCategoryByProductType(productType);
    }
    public List<Category> findAllIds(List<Long> listIds){
        List<Category> res = new ArrayList<Category>();
        for (Iterator<Long> it = listIds.iterator(); it.hasNext();) {
            Long idLong = it.next();
            Category mat = this.get(idLong);
            if(mat!=null)
                res.add(mat);
        }
        return res;
    }


}

